<script>
import Vue from 'vue';
export default {
	onLaunch: function() {
		// #ifdef MP-WEIXIN
		const updateManager = uni.getUpdateManager();
		updateManager.onUpdateReady(function(res) {
			updateManager.applyUpdate();
		});
		// #endif
		// #ifdef APP-PLUS
		// 应用启动后，用户有可能改变系统外观，这时候可以通过监听切换暗黑模式事件进行处理
		var style = plus.navigator.getUIStyle();
		if ('dark' == style) {
			console.log('当前为暗黑模式');
			this.$switchTheme('dark');
		} else {
			console.log('当前为普通模式');
			this.$switchTheme();
		}
		// 初始化获取当前系统外观模式
		uni.onThemeChange(function(res) {
			if ('dark' == res.style) {
				console.log('当前为暗黑模式');
				this.$switchTheme('dark');
			} else {
				console.log('当前为普通模式');
				this.$switchTheme();
			}
		});
		// #endif
		uni.getSystemInfo({
			success: function(e) {
				// #ifndef MP
				Vue.prototype.StatusBar = e.statusBarHeight;
				if (e.platform == 'android') {
					Vue.prototype.CustomBar = e.statusBarHeight + 50;
				} else {
					Vue.prototype.CustomBar = e.statusBarHeight + 45;
				}
				// #endif
				// #ifdef MP-WEIXIN
				Vue.prototype.StatusBar = e.statusBarHeight;
				let custom = wx.getMenuButtonBoundingClientRect();
				Vue.prototype.Custom = custom;
				Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif
				// #ifdef MP-ALIPAY
				Vue.prototype.StatusBar = e.statusBarHeight;
				Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
				// #endif
			}
		});
	},
	onShow: function() {
		console.log('App Show');
	},
	onHide: function() {
		console.log('App Hide');
	}
};
</script>

<style lang="scss">
@import 'colorui/main.css';
@import 'colorui/icon.css';

/* 引入主题样式 */
@import 'common/css/theme.scss'; // 默认主题
@import 'common/css/theme-dark.scss'; // 暗黑主题
@import 'common/css/main.scss';
</style>
